﻿<DataListSpec 
	xmlns="bb_appfx_datalist"
	xmlns:common="bb_appfx_commontypes" 
 	ID="b869a975-5619-4eca-ba24-2c9e3d031c7f" 
	Name="PledgesForConstituent Data List"
	Description="Returns pledge records assciated with a constituent." 
	Author="Blackbaud Professional Services"
	common:SecurityUIFolder="Service Bus Adapter">

	<!-- define the SP that returns the data for the datalist -->
	<SPDataList SPName="USP_DATALIST_PLEDGESFORCONSTITUENT">
		<common:CreateProcedureSQL>
			<![CDATA[
create procedure dbo.USP_DATALIST_PLEDGESFORCONSTITUENT
( @CONSTITUENTID uniqueidentifier)
as
	set nocount on;

	SELECT  
	r.ID, r.CONSTITUENTID, 
	d.USERID as DESIGNATIONNAME,
  r.DATE, r.POSTDATE, rs.AMOUNT, r.DESCRIPTION, r.LOOKUPID, 
	r.TRANSACTIONTYPE, rs.APPLICATION, rs.TYPE,
  r.DATEADDED,
  r.DATECHANGED,
  ca.USERNAME as CHANGEDBYUSERNAME,
  rs.DESIGNATIONID
  

FROM REVENUE r
	INNER JOIN REVENUESPLIT rs ON r.ID = rs.REVENUEID
	LEFT JOIN DESIGNATION d ON rs.DESIGNATIONID = d.ID
  LEFT OUTER JOIN CHANGEAGENT           ca  ON ca.ID                      = r.CHANGEDBYID



WHERE r.TRANSACTIONTYPE = 'Pledge'
	AND r.CONSTITUENTID = @CONSTITUENTID



]]>
		</common:CreateProcedureSQL>
	</SPDataList>


	<!--describe any parameters (other than the context ID) defined on the SP -->
	<Parameters>
		<common:FormMetaData>
			<common:FormFields>
        <common:FormField FieldID="CONSTITUENTID" Caption="Constituent ID" DataType="Guid"/>
      </common:FormFields>
		</common:FormMetaData>
	</Parameters>

	<!-- define the output fields in the list -->
	<Output>
		<OutputFields>
      <!-- 0 -->
      <OutputField FieldID="ID" Caption="ID" DataType="Guid" IsHidden="true" />
      <!-- 1 -->
      <OutputField FieldID="CONSTITUENTID" Caption="CONSTITUENTID" DataType="Guid" IsHidden="true" />
      <!-- 2 -->
      <OutputField FieldID="DESIGNATIONNAME" Caption="DESIGNATIONNAME" DataType="String"  />
      <!-- 3 -->
      <OutputField FieldID="DATE" Caption="DATE" DataType="Date" />
      <!-- 4 -->
      <OutputField FieldID="POSTDATE" Caption="POSTDATE" DataType="Date" />
      <!-- 5 -->
      <OutputField FieldID="AMOUNT" Caption="AMOUNT" DataType="Money" />
      <!-- 6 -->
      <OutputField FieldID="DESCRIPTION" Caption="DESCRIPTION" DataType="String" />
      <!-- 7 -->
      <OutputField FieldID="LOOKUPID" Caption="LOOKUPID" DataType="String" />
      <!-- 8 -->
      <OutputField FieldID="TRANSACTIONTYPE" Caption="TRANSACTIONTYPE" DataType="String" />
      <!-- 9 -->
      <OutputField FieldID="APPLICATION" Caption="APPLICATION" DataType="String" />
      <!-- 10 -->
      <OutputField FieldID="TYPE" Caption="TYPE" DataType="String" />
      <!-- 11 -->
      <OutputField FieldID="DATEADDED" Caption="Date Added" DataType="Date" />
      <!-- 12 -->
      <OutputField FieldID="DATECHANGED" Caption="Date Changed" DataType="Date" />
      <!-- 13 -->
      <OutputField FieldID="CHANGEDBYUSERNAME" Caption="Changed by User Name" DataType="String" />
      <!-- 14 -->
      <OutputField FieldID="DESIGNATIONID" Caption="Designation ID" DataType="Guid" />
    
    </OutputFields>
	</Output>

</DataListSpec>
